#include "config.h"
#include "MyGPIO.h"
#include "MyBlue.h"
#include "MyTimer.h"

u8 Data,i;

void main()
{
	GPIO_Init();
	UART_config();
	Timer0_INIT();
	P11=0;
    MA = 1;
	MB = 1;
	while(1)
	{

	}
}

void timer0_int (void) interrupt TIMER0_VECTOR
{
	if(Data){TX1_write2buff(Data);Data=0;}
}

/*****串口中断响应函数*************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************/
void UART1_int (void) interrupt UART1_VECTOR
{
	if(RI)
	{
		RI = 0;
		if(COM1.B_RX_OK == 0)
		{
			Data = SBUF;
			if(Data == 0x01){Yin=1;}//松手切换音道
			else{Yin=0;}
			
			if(Data == 0x30){Delay_ms(100);MA=1;MB=0;}
			else if(Data == 0x31){Delay_ms(100);MA=0;MB=2;}
			else{MA=1;MB=1;}
		}
	}
	if(TI)
	{
		TI = 0;
		if(COM1.TX_read != COM1.TX_write)
		{
		 	SBUF = TX1_Buffer[COM1.TX_read];
			if(++COM1.TX_read >= COM_TX1_Lenth)		COM1.TX_read = 0;
		}
		else	COM1.B_TX_busy = 0;
	}
}
